<template>
  <div>
      <el-cascader  
	        style="width:650px;"
	        v-model="bindList"
            placeholder="选择设备信息"
            :options="options"
            filterable
			@change="selectChange"
          />
  </div>
</template>

<script lang="ts" setup>
import {  onMounted,ref } from 'vue';
import request from '/@/utils/request';
interface ListItem {
  id: number,
  key:string,
  label:string,
  value:any,
  children:[]
}
var props = defineProps({
		paramter: {
		type: String,
		default: "",
	},
	info:{
		default:{}
		}
	});

const options = ref<ListItem[]>([])

let value=ref<any>()
let bindList=ref<any[]>()
//定义一个回调方法
const emit = defineEmits(["callBack"]);

onMounted(async() => {
	await getInfos()
	 if(props.paramter!=null&&props.paramter!="")
		bindList.value= JSON.parse(props.paramter)
})

const getInfos = async () => {
		  var url = `api/Common/EquiCascader/2`
		  var res = await request({url: url,method: 'get'});
		  options.value= res.data.result;
	};
	//调用父组件的一个方法将子组件值传过去
const selectChange=(item)=>{
	emit("callBack",JSON.stringify(item));
}
</script>